<!--
 * @Author: hq
 * @Date: 2022-05-26 21:33:00
 * @LastEditors: hq
 * @LastEditTime: 2022-06-16 13:34:49
 * @Description: your project
 * @version: 1.0
-->
<template>
  <div>
    <div class="row">
      <div class="title">商品名：</div>
      <!-- <el-select v-model="value" filterable placeholder="请选择">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select> -->
      <el-select
        v-model="goodsId"
        @change="changeSelect"
        placeholder="请选择"
        data-live-search="true"
      >
        <div class="search">
          <el-input
            class="search_input"
            type="text"
            v-model="searchText"
            clearable
            placeholder="请输入商品名称"
          ></el-input>
          <el-button type="primary" @click="handleSearchGoods">搜素</el-button>
        </div>
        <el-option
          v-for="item in goodsArr"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        ></el-option>
      </el-select>
    </div>
    <div class="row">
      <div class="title">分类：</div>
      <el-select v-model="typeId" placeholder="请选择">
        <el-option
          v-for="item in typeArr"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
    </div>
    <div class="row">
      <div class="title">排序：</div>
      <el-input
        oninput="value=value.replace(/^\.+|[^\d.]/g,'')"
        maxlength="3"
        v-model="sort"
        placeholder="请输入排序"
      >
      </el-input>
    </div>
    <div class="row">
      <div class="title">置顶：</div>
      <el-switch v-model="state" :active-color="$color - primary1"> </el-switch>
    </div>
    <div class="row">
      <div class="title"></div>
      <el-button type="primary">提交</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      goodsArr: [
        {
          value: "选项1",
          label: "黄金糕",
        },
        {
          value: "选项2",
          label: "双皮奶",
        },
        {
          value: "选项3",
          label: "蚵仔煎",
        },
        {
          value: "选项4",
          label: "龙须面",
        },
        {
          value: "选项5",
          label: "北京烤鸭",
        },
      ],
      searchText: "",
      typeArr: [
        {
          value: "选项1",
          label: "黄金糕",
        },
        {
          value: "选项2",
          label: "双皮奶",
        },
        {
          value: "选项3",
          label: "蚵仔煎",
        },
        {
          value: "选项4",
          label: "龙须面",
        },
        {
          value: "选项5",
          label: "北京烤鸭",
        },
      ],
      goodsId: "",
      typeId: "",
      value: [],
      list: [],
      loading: false,
      state: true,
    };
  },
  methods: {
    handleSearchGoods() {
      this.goodsArr = [
        {
          value: "选项1",
          label: "黄金糕",
        },
      ];
    },
    //改变选择的值立即直接
    changeSelect() {
      this.goodsArr = this.typeArr;
    },
  },
};
</script>

<style lang="scss" scoped>
.row {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  .title {
    width: 100px;
    text-align: end;
  }
  .el-select {
    width: 50%;
  }
  .el-input {
    width: 50%;
  }
  .el-button {
    margin-top: 20px;
  }
}
.search {
  display: flex;
  padding-left: 10px;
  box-sizing: border-box;
  .el-input {
    width: 60%;
    margin-right: 10px;
  }
}
</style>
